/*
 * 699.cpp
 * Copyright (C) 2015 libo <libo@tencent.com>
 *
 * Distributed under terms of the MIT license.
 */

#include <iostream>
#include <cstring>

using namespace std;

const int max_spend = 100;

int sum[max_spend];

// p is the central idx
int build(int p) {
  int root; cin >> root;
  if (root == -1) return -1;
  sum[p] += root;
  build(p-1);
  build(p+1);
  return 0;
};

bool init() {
  memset(sum, 0, max_spend);
  int central_idx = max_spend / 2;
  int ret = build(central_idx);
  return ret == 0;
};

int main() {
  int case_id = 0;
  while (init()) {
    int idx = 0;
    while (sum[idx] == 0) ++idx;
    cout << "Case " << case_id++ << ":\n";
    while (sum[idx] != 0) cout << sum[idx++] << " ";
    cout << "\n\n";
  }
  return 0;
}
